package com.binarysearch;

public class Solution69 {
    public int mySqrt(int x) {
        int i = 0;
        int j = x;
        while (i < j) {
            int mid = (i + j + 1) >> 1;
            if (mid == x / mid) return mid;
            else if (mid < x / mid) i = mid;
            else j = mid - 1;
        }
        return i;
    }
}
